package finalproject.config;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import finalproject.model.items.Coffee;
import finalproject.model.items.Item;
import finalproject.model.items.PetFood;
import finalproject.model.items.PowerDrink;
import finalproject.model.items.Tablets;
import finalproject.model.rooms.Clinic;
import finalproject.model.rooms.Corridor;
import finalproject.model.rooms.ExamRoom;
import finalproject.model.rooms.Gym;
import finalproject.model.rooms.LabRoom;
import finalproject.model.rooms.LectureRoom;
import finalproject.model.rooms.Library;
import finalproject.model.rooms.LunchRoom;
import finalproject.model.rooms.PetClinic;
import finalproject.model.rooms.PetExchangeRoom;
import finalproject.model.rooms.Room;
import finalproject.model.rooms.SecretRoom;
import finalproject.model.rooms.Teleport;
import finalproject.model.rooms.Trap;
import finalproject.model.rooms.TreasureRoom;
import finalproject.model.studies.Lab;
import finalproject.model.studies.Lecture;
import finalproject.model.studies.Topic;

/**
 * The class containing all the hardcoded resources
 * @author Nicolas Bighetti & Yassine Tijani
 *
 */
public class Ressource {

	/**
	 * The total number of course and Lab
	 */
	private static final int NB_COURSE = 1;

	/**
	 * The common prefixe for the lecture
	 */
	private static final String LECTURE = "lecture";
	/**
	 * The common suffixe for the lecture
	 */
	private static final String LAB = "lab";

	public static final Lecture otherCourse = new Lecture("Something", Topic.BIO, new Lab("blahblah", Topic.BIO));
	public static final Lab otherLab = new Lab("someLab", Topic.BIO);

	/**
	 * The list of every lab session
	 */
	public static final List<Lab> listLab = loadLab();
	/**
	 * The list of every lecture
	 */
	public static final List<Lecture> listCourse = loadCourse();

	/**
	 * The pool for every exam Questions
	 */
	private static Map<String, Boolean> examQuestions = loadExamQuestions();

	/**
	 * The room list
	 */
	private static List<Room> roomList = loadRoomList();
	
	/**
	 * The item list
	 */
	private static List<Item> itemList = loadItemList();
	
	/**
	 * A method which load every course
	 * @return a list containing every course
	 */
	private static List<Lecture> loadCourse()
	{
		ArrayList<Lecture> course = new ArrayList<Lecture>();
		Lecture currentCourse;

		for(int i = 1; i <= NB_COURSE; i++)
		{
			currentCourse = new Lecture(LECTURE + i, Topic.OOP, listLab.get(i-1));
			course.add(currentCourse);
		}

		return course;

	}

	/**
	 * A method loading every item
	 * @return a list of every item
	 */
	private static List<Item> loadItemList() {
		// TODO Auto-generated method stub
		ArrayList<Item> items = new ArrayList<Item>();
		
		items.add(new Coffee());
		items.add(new Tablets());	
		items.add(new PetFood());
		items.add(new PowerDrink());
		
		return items;
	}

	/**
	 * A method loading every room
	 * @return a list of every room
	 */
	private static List<Room> loadRoomList() {
		// TODO Auto-generated method stub
		ArrayList<Room> rooms = new ArrayList<Room>();
		rooms.add(new LunchRoom("lunch room"));

		//TODO : enlever le paramètre exam de ExamRoom, instancier plus tard
		
		rooms.add(new ExamRoom("exam room", null));
		rooms.add(new Library("library"));
		rooms.add(new Corridor("corridor 1", false));
		rooms.add(new Corridor("corridor 2", true));
		rooms.add(new Corridor("corridor 3", false));

		rooms.add(new LectureRoom("LectureRoom 1", null));
		rooms.add(new LectureRoom("LectureRoom 2", null));
		rooms.add(new LectureRoom("LectureRoom 3", null));
		rooms.add(new LectureRoom("LectureRoom 4", null));

		rooms.add(new LabRoom("LabRoom 1", null));
		rooms.add(new LabRoom("LabRoom 2", null));
		rooms.add(new LabRoom("LabRoom 3", null));
		rooms.add(new LabRoom("LabRoom 4", null));
	
		rooms.add(new Clinic("Clinic", true));
		
		rooms.add(new PetClinic("Pet Clinic", true));
		
		rooms.add(new TreasureRoom("TreasureRoom 1", true));
		rooms.add(new TreasureRoom("TreasureRoom 2", true));
		rooms.add(new TreasureRoom("TreasureRoom 3", true));
		
		rooms.add(new Trap("Clinic", true));
		rooms.add(new Trap("Pet Clinic", true));
		rooms.add(new Trap("LabRoom 1", true));
		
		
		rooms.add(new Teleport("Teleport 1", true));
		rooms.add(new Teleport("Teleport 2", true));
		rooms.add(new Teleport("Teleport 3", true));
		
		rooms.add(new SecretRoom("SecretRoom", true));
		rooms.add(new SecretRoom("SecretRoom", true));
		rooms.add(new SecretRoom("SecretRoom", true));
		rooms.add(new SecretRoom("SecretRoom", true));
		rooms.add(new PetExchangeRoom("PetExchangeRoom", true));
		rooms.add(new PetExchangeRoom("PetExchangeRoom", true));
		rooms.add(new PetExchangeRoom("PetExchangeRoom", true));
		rooms.add(new PetExchangeRoom("PetExchangeRoom", true));
		rooms.add(new Gym("Gym", true));
		rooms.add(new Gym("Gym", true));
		rooms.add(new Gym("Gym", true));
		rooms.add(new Gym("Gym", true));
		
		return rooms;
	}

	/**
	 * @return the room list
	 */
	public static List<Room> getRoomList()
	{
		return roomList;
	}
	
	/**
	 * @return the exam question pool
	 */
	private static Map<String, Boolean> loadExamQuestions() {
		// TODO Auto-generated method stub
		HashMap<String, Boolean> examData = new HashMap<String, Boolean>();
		examData.put("question1", true);
		examData.put("question2", false);
		examData.put("quetion3", false);
		examData.put("question4", false);
		examData.put("question5", true);

		return examData;
	}


	/**
	 * @return the list of every lab session
	 */
	private static List<Lab> loadLab()
	{
		ArrayList<Lab> lab = new ArrayList<Lab>();
		Lab currentLab;

		for(int i = 1; i <= NB_COURSE; i++)
		{
			currentLab = new Lab(LAB + i, Topic.OOP);
			lab.add(currentLab);
		}

		return lab;
	}

	/**
	 * @return The number of question
	 */
	public static int getNumberOfQuestion()
	{
		return examQuestions.size();
	}

	/**
	 * Return the answer to a question
	 * @param key the question you want the answer for
	 * @return the answer
	 */
	public static Boolean getAnwser(String key)
	{
		try
		{
			return examQuestions.get(key);
		}
		catch(Exception e)
		{
			//TODO : Throw exception?
			return null;
		}
	}

	public static List<Item> getItemList() {
		return itemList;
	}




}
